<style lang="sass" scoped>
    .system{
        li{
            display:inline-block; 
        }  
    }
    .system li a:hover{color:#fff!important;}
    .block_alert_cheng .conmain{
        min-width:500px;
    }
    .danger{
        background:#fbd5d5;
    }
    .main{
        padding:20px;
        border:solid 1px #ddd;
        background:#fff;
        border-top:none;
        padding-bottom:30px;
    }
    .table-bordered{
        th{
            text-align:center;
        }
    }
</style>

<template>
<div class="container-fluid">
    <div class="row comm_conent_padding">
        <nav-bar><li slot="nav_two">系统管理</li></nav-bar>

        <!-- 系统列表 -->
        <div class="block">
            <div class="block">
                <select class="form-control w-100 inline_block" v-model="search.pushType" v-on:change="getDatas">
                    <option value="">选择类型</option>
                    <option value="0">系统</option>
                    <option value="1">活动</option>
                </select>
                <select v-model="company" class="form-control w-150 inline_block mr20" v-on:change="getDatas">
                    <option :value="{}">选择公司</option>
                    <option 
                        v-Jurisdiction="item.onlneCode" 
                        v-for="item in sysList" 
                        :value="item">{{ item.companyName }}</option>
                </select>
                <select v-if="search.pushType == 0 ?true:false" v-model="system" class="form-control w-250 inline_block mr20" v-on:change="getDatas">
                    <option :value="{}">选择系统</option>
                    <option 
                        v-Jurisdiction="item.onlneCode" 
                        v-for="item in systems" 
                        :value="item">{{ item.sysCode +'--'+item.sysName }}</option>
                </select> 
            </div>

            <div class="table-responsive mt20" v-show="datalist.length">
                <table class="table table-bordered table_color">
                    <tr class="tr_info">
                        <th class="w-80">发布人员</th>
                        <th class="w-150">发布时间</th>
                        <th class="w-100">发布类型</th>
                        <th>发布说明</th>
                        <th class="w-80">发布结果</th>
                        <th>系统名称</th>
                        <th class="w-250">系统编码</th>
                        <th>公司名称</th>
                        <th>公司编码</th>
                    </tr>
                    <tr :class="{'danger':item.isUse==0?true:false}" v-for="item in datalist">
                        <td class="tc" v-text="item.pushUser"></td>
                        <td class="tc" >{{item.pushTime|date('-',true)}}</td>
                        <td class="tc" v-text="item.pushType==1?'活动':'系统'"></td>
                        <td class="tc" v-text="item.pushSystem"></td>
                        <td class="tc red" :class="{'green':item.pushResult==0?true:false}" v-text="item.pushResult==0?'成功':'失败'"></td>
                        <td class="tc" v-text="item.sysName"></td>
                        <td class="tc" v-text="item.sysCode"></td>
                        <td class="tc" v-text="item.companyName"></td>
                        <td class="tc" v-text="item.companyCode"></td>
                    </tr>
                </table>  
                <div class="tr mt20">
                    <page :is-search="search.isSearch" :now-page="search.pageNo" :page-size="search.pageSize" :total-count="search.totalCount" @onPropsChange="change"></page>
                </div> 
            </div>

            <div class="tc mt30" v-show="!datalist.length">还没有发布日志!</div>
        </div>

    </div>    
</div>
</template>

<script>
    import navBar from 'components/navBar' 
    import page from 'components/page'

    export default {
        components: {
            navBar,
            page,
        },
        data(){
            return {
                sysList:[],
                company:{},
                systems:[],
                system:{},
                search:{
                    pageSize:20,
                    pageNo: this.$route.query.page || 1, //  否   int 默认 1
                    pushType:'',
                    sysCode:'',
                    companyCode:'',
                    isSearch:false,
                    totalCount:0,
                    systemType:0, //正式环境
                },
                datalist:[],
            }
        },
        watch:{
            'company'(){
                this.systems = this.company.systems;
            },
            '$route'(to, from) {
                this.search.pageNo = to.query.page || 1;
                this.getDatas();
            },
        },
        mounted() {
            this.$nextTick(()=>{
                this.getSystems();
                this.getDatas();
            })
        },
        methods: {
            change(prop,val){
                this.search[prop]=val;
            },
            // 获得系统列表
            getSystems(){
                util.ajax({
                    url:config.baseApi+'api/getComSysDataList',
                    success:data=>{
                        this.sysList=data.data
                    }
                })
            },

            // 获得日志数据
            getDatas(){
                this.search.sysCode     = this.system.sysCode
                this.search.companyCode = this.company.companyCode

                util.ajax({
                    url:config.baseApi+'api/getPushLogsDatas',
                    data:this.search,
                    success:data=>{
                        this.datalist = data.data.datalist
                        this.search.totalCount = data.data.totalNum
                    }
                })
            },
           
        },
    }
</script>


